package com.woniuxy.education.controller;

import com.woniuxy.education.entity.Ncee;
import com.woniuxy.education.entity.Question_ask;
import com.woniuxy.education.service.QuestionAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
//问题解答+高考数据录入
public class QuestionAnswerController {
    @Autowired
    QuestionAnswerService questionAnswerService;
    //获取提问信息
    @RequestMapping("/findQuestion_ask")
    public List<Question_ask> selectByState(String userid) {
        List<Question_ask> questionAsks = questionAnswerService.getQuestionAsk(userid);

       // System.out.println(questionAsks);
        return questionAsks;
    }
    //回复
    @RequestMapping("/AnswerQuestion")
    public String selectByState(String id, String qustionAnswer) {
        // System.out.println(id);
        // System.out.println(qustionAnswer);

        try {
            //回复
            questionAnswerService.insertQuestionAnswer(id,qustionAnswer);
        }catch (Exception e){
            System.out.println(e);
            return "201";
        }

        return "200";
    }

    //高考数据录入
    @RequestMapping("/nceeEntering")
    public String nceeEntering( Ncee ncee,int synthesize_score,String synthesize_score_name) {
        //System.out.println(ncee);
        //.out.println(synthesize_score);
        //System.out.println(synthesize_score_name);
        if("理综".equals(synthesize_score_name)){
            ncee.setScience_synthesize(synthesize_score);
        }
        else {
            ncee.setArts_synthesize(synthesize_score);
        }
        try {
            //录入
            questionAnswerService.insertNceeData(ncee);
        }catch (Exception e){
            System.out.println(e);
            return "201";
        }

        return "200";
    }
}
